package com.foreknow.demo03;

import java.util.Scanner;
import java.util.function.DoubleToIntFunction;

public class ZuoYe0607 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("---------------------------------");
        System.out.println(" **********   欢迎登陆  **********");
        System.out.println(" *********   中国人民银行 *********");
        System.out.println(" *********    版本1.0   *********");
        System.out.println("---------------------------------");
        //各种初始声明
        String id = "admin";
        //登陆对比
        String id1 = "";
        String password = "123";
        //登陆对比
        String password1="";
        //改密码登录
        String password2="";
        //新密码1
        String password3="";
        //确认新密码
        String password4="";
        boolean isRight= true;
        int money=10000;
        int cun=0;
        int qu = 0;

        for (int i =1;i<=3;i++){
            System.out.println("请输入账号：");
            id1 = input.next();
            System.out.println("请输入密码：");
            password1 = input.next();
            if(id.equals(id1) && password.equals(password1)){
                System.out.println("登陆成功");


                do{
                    System.out.println("1.查询余额 2.存款 3.取款 4.修改密码 5.退出");
                    int choose = input.nextInt();
                    switch (choose){
                        case 1:
                            System.out.println("您的余额为："+money);
                            break;

                        case 2:
                            System.out.println("请输入您要存款的金额：");
                            //输入存款金额
                            cun = input.nextInt();
                            if(cun%100 !=0){
                                System.out.println("请存入100的整数倍存款");
                                break;
                            }else if ( cun<0){
                                System.out.println("存款金额错误");
                                break;
                            }else if(cun >10000){
                                System.out.println("单次存款金额超过一万");
                                break;
                            }else{
                                money+=cun;
                                System.out.println("存款成功，当前余额为"+money);
                            }
                            break;
                        case 3:
                            System.out.println("请输入您要取款的金额：");
                            qu = input.nextInt();
                            if( qu > money){
                                System.out.println("余额不足");
                                break;
                            }else if (qu >3000){
                                System.out.println("单词取款金额超过3000");
                                break;
                            }else if(qu<0){
                                System.out.println("取款金额错误");
                                break;
                            }else if(qu % 100 !=0){
                                System.out.println("请取出100的整数倍存款");
                                break;
                            }else{
                                money-=qu;
                                System.out.println("取款成功，当前余额为"+money);
                            }
                            break;

                        case 4:
                            System.out.println("请输入旧密码");
                            password2 = input.next();
                            if (!password2.equals(password)){
                                System.out.println("旧密码输入错误");
                                System.out.println("当前密码为"+password);
                                break;
                            }
                            System.out.println("请输入新密码：");
                            password3= input.next();
                            System.out.println("请再次输入新密码：");
                            password4= input.next();

                            if(password3.equals(password4)){
                                password =  password3;
                                System.out.println("修改成功，您的新密码为："+password);
                            }else {
                                System.out.println("两次输入密码不一致，请重新输入");
                                break;
                            }
                            break;

                        case 5 :
                            isRight = true;
                            break;

                    }

                    System.out.println("是否继续操作(y/n)");
                    String ans=input.next();
                    if(ans.equals("y")){
                        isRight = false;
                    }else{
                        isRight = true;
                    }

                }while(!isRight);
                System.out.println("退出成功");

            //以上为登陆成功操作
            }else if(i<3){
                System.out.println("账号或者密码错误，今日还剩余"+(3-i)+"次机会");
            }else{
                System.out.println("密码错误3次，吞卡，请找老司机处理");
            }

        }




    }

}
